package com.shtel.bss.saas.tenant.service.impl;

import com.github.pagehelper.PageInfo;
import com.shtel.bss.saas.core.data.common.service.DataServiceImpl;
import com.shtel.bss.saas.tenant.bo.SysRoleBo;
import com.shtel.bss.saas.tenant.entity.SysRole;
import com.shtel.bss.saas.tenant.manager.SysRoleManager;
import com.shtel.bss.saas.tenant.mapstrut.EntityDtoMapper;
import com.shtel.bss.saas.tenant.service.ISysRoleService;
import org.springframework.stereotype.Service;

/**
 * 角色表服务
 *
 * @author xiezhiwei 2020-02-05 22:02
 */
@Service("SysRoleService")
public class SysRoleServiceImpl extends DataServiceImpl implements ISysRoleService {
    @Override
    public PageInfo<SysRoleBo> qrySysRoleList(SysRoleBo sysRoleBo, int pageNum, int pageSize) {
        return EntityDtoMapper.INSTANCE.toSysRoleBoPageInfo(SysRoleManager.selectEntity(EntityDtoMapper.INSTANCE.toSysRole(sysRoleBo), pageNum, pageSize));
    }

    @Override
    public SysRoleBo qrySysRole(SysRoleBo sysRoleBo) {
        return EntityDtoMapper.INSTANCE.toSysRoleBo(SysRoleManager.selectOne(EntityDtoMapper.INSTANCE.toSysRole(sysRoleBo)));
    }

    @Override
    public void saveSysRole(SysRoleBo sysRoleBo) {
        SysRoleManager.saveEntity(EntityDtoMapper.INSTANCE.toSysRole(sysRoleBo));
    }

    @Override
    public void updateSysRole(SysRoleBo sysRoleBo) {
        SysRoleManager.updateEntity(EntityDtoMapper.INSTANCE.toSysRole(sysRoleBo));
    }

    @Override
    public void removeSysRole(Long roleId) {
        SysRole sysRole = new SysRole();
        sysRole.setRoleId(roleId);
        sysRole.setIsDelete((byte) 1);
        SysRoleManager.updateEntity(sysRole);
    }
}